package com.itheima.d7_polymorphism.demo2;

/**
 * 多态练习 解耦合 的好处
 */
public class Test {
    public static void main(String[] args) {
        Wolf w = new Wolf();
        Tortoise t = new Tortoise();
        run(w);
        run(t);

    }
    public static void run(Animal a){
        System.out.println("===========");
        if(a instanceof Wolf w){
            w = (Wolf)a;
            w.eatSheep();
        }else if(a instanceof Tortoise t){
            t.run();
        }


        //子类的特有方法不能够访问
        //a.eat();

    }
}
